package com.yz.jdd.module.main;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;

import com.yz.jdd.R;
import com.yz.jdd.webview.Router;

public class ActivityPopupWindow extends Activity implements View.OnClickListener {

    String router;
    String salesManagerTel;
    String erro;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_popup_window);
        getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT);
        salesManagerTel=getIntent().getStringExtra("salesManagerTel");
        router=getIntent().getStringExtra("router");
        erro=getIntent().getStringExtra("erro");


        findViewById(R.id.touch_outside).setOnClickListener(this);
        findViewById(R.id.call_salesManager).setOnClickListener(this);

        findViewById(R.id.call_kefu).setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
        if(view.getId()==R.id.touch_outside){
            finish();
        }else if(view.getId()==R.id.call_kefu){
            Intent intent = new Intent(Intent.ACTION_DIAL);
            Uri data = Uri.parse("tel:" + "400-109-9960");
            intent.setData(data);
            startActivity(intent);
        }else if(view.getId()==R.id.call_salesManager){
            if(!TextUtils.isEmpty(salesManagerTel)){
                Intent intent = new Intent(Intent.ACTION_DIAL);
                Uri data = Uri.parse("tel:" + salesManagerTel);
                intent.setData(data);
                startActivity(intent);
            }else if(!TextUtils.isEmpty(router)){
                Router.startWebView(this,router);
            }else if(!TextUtils.isEmpty(erro)){
                Toast.makeText(ActivityPopupWindow.this,erro,Toast.LENGTH_SHORT).show();
            }

        }
    }
}
